﻿using PmSoft.Entity;
using PmSoft.PetaPoco.Extend;

namespace PmSoft.ApplicationContext;

public interface IApplicationContext
{
    /// <summary>
    /// 当前登录用户
    /// </summary>
    IUser? CurrentUser { get; }
    /// <summary>
    /// 请求URL
    /// </summary>
    string? RequestUrl { get; }
    /// <summary>
    /// 客户端IP
    /// </summary>
    string? ClientIp { get; }
    bool IsAuthenticated { get; }
    T? As<T>() where T : class, IApplicationContext;
    T? GetStateResolver<T>(string name);
    void SetStateResolver(string name, object value);
    /// <summary>
    /// 获取服务
    /// </summary>
    /// <typeparam name="TService"></typeparam>
    /// <returns></returns>
    TService GetService<TService>();
    /// <summary>
    /// 是否为DEBUG模式
    /// </summary>
    bool IsDebugMode { get; }
    /// <summary>
    /// 数据库事务
    /// </summary>
    IDbContextTransaction Transaction { get; }
}
